﻿using KayakMes.Check.Application.CheckStandard;
using KayakMes.Check.Application.Input;
using KayakMes.Check.Application.OUT;
using KayakMes.Check.Domain;
using KayakMes.Common;
using KayakMes.Common.Dtos.CheckDto;
using KayakMes.Common.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Yitter.IdGenerator;


namespace KayakMes.Check.API.Controllers
{
    /// <summary>
    /// 检测标准
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CheckStandardController : ControllerBase
    {
        private readonly ICheckStandard _checkStandard;
        public CheckStandardController(ICheckStandard checkStandard)
        {
            _checkStandard = checkStandard;
        }
        /// <summary>
        /// 添加检测标准
        /// </summary>
        /// <param name="checkStandard"></param>
        /// <returns></returns>
        /// 
        [HttpPost]
        public ApiResult<int> AddCheckStandard([FromBody]AddCheckStandardInput input)
        {
          return _checkStandard.AddCheckStandard(input);
        }
        /// <summary>
        /// 删除检查标准
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<int> DeleteCheckStandard(long Id)
        {
          return _checkStandard.DeleteCheckStandard(Id);
        }
        /// <summary>
        /// 获取所有检查标准分页
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiPaging<CheckStandardDto> GetAllCheckStandard([FromQuery]GetCheckStandardInput input)
        {
           return _checkStandard.GetAllCheckStandard(input);
        }
        /// <summary>
        /// 获取所有单一标准
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<CheckStandardDetailResult> GetModelCheckStandard(long id)
        {
           return _checkStandard.GetModelCheckStandard(id);
        }
        /// <summary>
        /// 修改检测标准
        /// </summary>
        /// <param name="checkStandard"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpPut]
        public ApiResult<int> UpdateCheckStandard(UpdateCheckStandardInput checkStandard)
        {
           return _checkStandard.UpdateCheckStandard(checkStandard);

        }

        /// <summary>
        /// 随机生成检测项目编号
        /// </summary>
        /// <returns>格式为 PC001 的字符串</returns>
        /// 
        [HttpGet]
        public string GetCheckItemCode()
        {
           return _checkStandard.GetCheckItemCode();
        }

        /// <summary>
        /// 获取所有检测项目
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiPaging<ProcessCheckDto> GetAllCheck([FromQuery]GetCheckInput input)
        {
            return _checkStandard.GetAllCheck(input);
        }

        /// <summary>
        /// 检验完毕修改状态
        /// </summary>
        /// <param name="checkCode"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        /// 
        [HttpGet]
        public ApiResult<int> UpdateIselete([FromQuery]string checkCode)
        {
          return _checkStandard.UpdateIselete(checkCode);
        }

    }
}
